package com.sales.service.view;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.sales.service.R;

/**
 * This class is the page after Login Screen.
 * It extends to the Base Activity.
 * Its layout consists of six buttons.
 * Each button is to perform actions related with developerforce.com.
 * They are Event, Task, Lead, Account, Contacts and Opportunity.
 * Image Buttons are used.
 * 
 * @author Sega
 *
 */
public class MainPageActivity extends BaseActivity implements OnClickListener {

	/**
	 * Strings for debugging process by log.i method
	 */
	private static final String TagProject = "SalesService";
	private static final String TagPage = "MainPage ::";

//	ArrayList<String> https = new ArrayList<String>();

	/**
	 * Buttons are declared.
	 */
	Button btnEvent;
	Button btnTask;
	Button btnLead;
	Button btnAccount;
	Button btnContact;
	Button btnOpportunity;

	/* (non-Javadoc)
	 * @see com.sales.service.view.BaseActivity#onCreate(android.os.Bundle)
	 * 
	 * This is the onCreate overridden method.
	 * Here the buttons are instantiated.
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.main_layout);
		Log.i(TagProject, TagPage);

		btnEvent = (Button) findViewById(R.id.btnEvent);
		btnEvent.setOnClickListener(this);

		btnTask = (Button) findViewById(R.id.btnTask);
		btnTask.setOnClickListener(this);

		btnLead = (Button) findViewById(R.id.btnLead);
		btnLead.setOnClickListener(this);

		btnAccount = (Button) findViewById(R.id.btnAccount);
		btnAccount.setOnClickListener(this);

		btnContact = (Button) findViewById(R.id.btnContact);
		btnContact.setOnClickListener(this);

		btnOpportunity = (Button) findViewById(R.id.btnOpportunity);
		btnOpportunity.setOnClickListener(this);
	}

	/* (non-Javadoc)
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 * 
	 * This is the implemented method for onClickListener.
	 * All the buttons click event operations are defined here.
	 * Each call the respective layout.
	 */
	@Override
	public void onClick(View v) {

		switch (v.getId()) {
		case R.id.btnEvent:
			Intent intent1 = new Intent(MainPageActivity.this, EventActivity.class);
			startActivity(intent1);
			break;
		case R.id.btnTask:
			Intent intent2 = new Intent(MainPageActivity.this, TaskActivity.class);
			startActivity(intent2);
			break;
		case R.id.btnLead:
			Intent intent3 = new Intent(MainPageActivity.this, LeadActivity.class);
			startActivity(intent3);
			break;
		case R.id.btnAccount:
			Intent intent4 = new Intent(MainPageActivity.this, AccountActivity.class);
			startActivity(intent4);
			break;
		case R.id.btnContact:
			Intent intent5 = new Intent(MainPageActivity.this, ContactActivity.class);
			startActivity(intent5);
			break;
		case R.id.btnOpportunity:
			Intent intent6 = new Intent(MainPageActivity.this, OpportunityAcitvity.class);
			startActivity(intent6);
			break;
		}
	}

}

/*
 * ConnectivityManager cm = (ConnectivityManager)
 * getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo =
 * cm.getActiveNetworkInfo(); if (networkInfo != null &&
 * networkInfo.isConnected()) { Toast.makeText(getApplicationContext(),
 * "Performing MultiThreads. PLease wait",5000).show(); fillHttps();
 * 
 * for(String sites : https){ ServiceRequest sr = new ServiceRequest();
 * sr.setRequesturl(sites); ServiceQueueManager.getInstance().queuePut(sr); }
 * Log.i(TagProject, TagPage +
 * "Queue size : "+ServiceQueueManager.getInstance().queueSize());
 * 
 * Log.i(TagProject, TagPage + "Calling Singleton ThreadPool class.");
 * ServiceThreadPool.getInstance();
 * 
 * // ServiceTask asyncTask = new ServiceTask(); // asyncTask.execute(sr); }
 * else { Log.i(TagProject, TagPage + "No Internet Connection");
 * Toast.makeText(getApplicationContext(),
 * "No Internet connection",2000).show(); // System.exit(0); }
 */

// public void fillHttps(){
// https.add("http://www.google.com");
// https.add("http://www.gmail.com");
// https.add("http://www.yahoo.com");
// https.add("http://www.facebook.com");
// https.add("http://www.orkut.com");
// https.add("http://www.hdfcbank.com");
// https.add("http://www.lvbank.com");
// https.add("http://www.onlinesbi.com");
// https.add("http://www.icicibank.com");
// https.add("http://www.airtel.in");
// }
